package jpa4azure.type;

import static jpa4azure.util.TableHelper.getChildPartitionKeyColumn;
import static jpa4azure.util.TableHelper.getChildRowKeyColumn;

import java.lang.reflect.Field;

import com.windowsazure.samples.Property;
import com.windowsazure.samples.PropertyCollection;

public class CompoundFieldContext extends FieldContext {

	public CompoundFieldContext(Object o, Field field) {
		super(o, field);
	}

	
	
	public void getCloudTableColumn(PropertyCollection values) {
		Object value = value();
		if (value == null)
			return;
		Key key = TypeWrapperFactory.wrap(field.getType()).id(value);
		values.add(Property.newProperty(
				getChildRowKeyColumn(getFieldname()), key.getRow()));
		values.add(Property.newProperty(
				getChildPartitionKeyColumn(getFieldname()), key.getPartition()));		
	}


}
